package com.ship.system.api.factory;

import com.ship.system.api.RemoteDispatchService;
import com.ship.system.api.domain.dispatch.ShipInfoUpdateDto;
import com.ship.system.api.domain.dispatch.SimpleShipInfoVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.LinkedList;
import java.util.List;

/**
 * 通用服务降级处理
 * 
 * @author zhangyh
 */
@Component
public class RemoteDispatchFallbackFactory implements FallbackFactory<RemoteDispatchService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteDispatchFallbackFactory.class);

    @Override
    public RemoteDispatchService create(Throwable throwable)
    {
        log.error("调度服务调用失败:{}", throwable.getMessage());
        return new RemoteDispatchService()
        {

            @Override
            public String getShioCounty(String shipName, String imo) {
                return null;
            }

            @Override
            public void checkShipCrewStatus() {

            }

            @Override
            public void homeStatisticsCacheUpdate() {

            }

            @Override
            public void reportItemCacheUpdate() {

            }

            @Override
            public Boolean updateShipInfo(ShipInfoUpdateDto dto) {
                return false;
            }

            @Override
            public void dispatchExpireMessageSend() {

            }

            @Override
            public void portRouteRelationUpdate() {

            }

            @Override
            public List<SimpleShipInfoVo> getAllSimpleShipList() {
                return new LinkedList<>();
            }

            @Override
            public void updateDispatchInfo(ShipInfoUpdateDto dto) {

            }

            @Override
            public void setShipImo() {

            }

            @Override
            public void setImoStatus() {

            }
        };
    }
}
